<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="记账单号" prop="goodsTransferAccountNumber">
        <el-input
          v-model="queryParams.goodsTransferAccountNumber"
          placeholder="请输入记账单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--el-form-item label="货转ID" prop="goodsTransferId">
        <el-input
          v-model="queryParams.goodsTransferId"
          placeholder="请输入货转ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货转单号" prop="goodsTransferNumber">
        <el-input
          v-model="queryParams.goodsTransferNumber"
          placeholder="请输入货转单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="原货权客户" prop="originGoodsRightCustomer">
        <el-select v-model="queryParams.originGoodsRightCustomer" placeholder="请选择原货权客户" clearable filterable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="新货权客户" prop="newGoodsRightCustomer">
        <el-select v-model="queryParams.newGoodsRightCustomer" placeholder="请选择新货权客户" clearable filterable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="货转状态" prop="goodsTransferStatus">
        <el-select v-model="queryParams.goodsTransferStatus" placeholder="请选择货转状态" clearable>
          <el-option
            v-for="dict in dict.type.goods_transfer_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="货转人" prop="goodsTransferPerson">
        <el-input
          v-model="queryParams.goodsTransferPerson"
          placeholder="请输入货转人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货转时间">
        <el-date-picker
          v-model="daterangeGoodsTransferTime"
          style="width: 205px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="货转重量(吨)" prop="goodsTransferWeight">
        <el-input
          v-model="queryParams.goodsTransferWeight"
          placeholder="请输入货转重量(吨)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="件数" prop="goodsTransferPiece">
        <el-input
          v-model="queryParams.goodsTransferPiece"
          placeholder="请输入件数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item-->
      <!--el-form-item label="结算状态" prop="goodsTransferSettlementStatus">
        <el-select v-model="queryParams.goodsTransferSettlementStatus" placeholder="请选择结算状态" clearable>
          <el-option
            v-for="dict in dict.type.settlement_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item-->
      <el-form-item label="结算客户" prop="goodsTransferSettlementCustomer">
        <el-select v-model="queryParams.goodsTransferSettlementCustomer" placeholder="请选择结算客户" clearable filterable>
          <el-option
            v-for="dict in customerOptions"
            :key="dict.customerId"
            :label="dict.customerName"
            :value="dict.customerName"
          />
        </el-select>
      </el-form-item>
      <!--el-form-item label="结算方式" prop="goodsTransferSettlementMode">
        <el-select v-model="queryParams.goodsTransferSettlementMode" placeholder="请选择结算方式" clearable>
          <el-option
            v-for="dict in dict.type.settlement_mode"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item-->
      <!--el-form-item label="免费次数" prop="goodsTransferFreeTimes">
        <el-input
          v-model="queryParams.goodsTransferFreeTimes"
          placeholder="请输入免费次数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货转单价(元/吨)" prop="goodsTransferPrice">
        <el-input
          v-model="queryParams.goodsTransferPrice"
          placeholder="请输入货转单价(元/吨)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收费重量(吨)" prop="goodsTransferChargeWeight">
        <el-input
          v-model="queryParams.goodsTransferChargeWeight"
          placeholder="请输入收费重量(吨)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="折扣模式" prop="goodsTransferDiscountMode">
        <el-select v-model="queryParams.goodsTransferDiscountMode" placeholder="请选择折扣模式" clearable>
          <el-option
            v-for="dict in dict.type.discount_mode"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="折扣额度" prop="goodsTransferDiscountAmount">
        <el-input
          v-model="queryParams.goodsTransferDiscountAmount"
          placeholder="请输入折扣额度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货转费用" prop="goodsTransferFee">
        <el-input
          v-model="queryParams.goodsTransferFee"
          placeholder="请输入货转费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="外部单号" prop="externalOrderNumber">
        <el-input
          v-model="queryParams.externalOrderNumber"
          placeholder="请输入外部单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账单编号" prop="billNumber">
        <el-input
          v-model="queryParams.billNumber"
          placeholder="请输入账单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账单状态" prop="billStatus">
        <el-select v-model="queryParams.billStatus" placeholder="请选择账单状态" clearable>
          <el-option
            v-for="dict in dict.type.bill_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="告警状态" prop="alarmStatus">
        <el-input
          v-model="queryParams.alarmStatus"
          placeholder="请输入告警状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="告警描述" prop="alarmDescription">
        <el-input
          v-model="queryParams.alarmDescription"
          placeholder="请输入告警描述"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区代码" prop="parkCode">
        <el-input
          v-model="queryParams.parkCode"
          placeholder="请输入园区代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item-->
      <el-form-item label="创建者" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入创建者"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterangeCreateTime"
          style="width: 205px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['transfers:account:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['transfers:account:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['transfers:account:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['transfers:account:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" @computeTable="computeTableHeight"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="accountList" @selection-change="handleSelectionChange" border :height="tableHeight" :row-style="{height:'35px'}" :cell-style="{padding:'0px'}">
      <el-table-column type="selection" width="45" align="center" />
      <el-table-column type="index" prop="" width="55" label="序号" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.$index+1 +(queryParams.pageNum-1)*queryParams.pageSize }}</span>
        </template>
      </el-table-column>
      <!--el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100%">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['transfers:account:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['transfers:account:remove']"
          >删除</el-button>
        </template>
      </el-table-column -->
      <!--el-table-column label="记账ID" align="center" prop="goodsTransferAccountId" /-->
      <el-table-column label="记账单号" align="center" prop="goodsTransferAccountNumber" width="160" :show-overflow-tooltip="true" />
      <!--el-table-column label="货转ID" align="center" prop="goodsTransferId" /-->
      <!--el-table-column label="货转单号" align="center" prop="goodsTransferNumber" width="160" :show-overflow-tooltip="true" /-->
      <el-table-column label="原货权客户" align="center" prop="originGoodsRightCustomer" width="300" :show-overflow-tooltip="true" />
      <el-table-column label="新货权客户" align="center" prop="newGoodsRightCustomer" width="300" :show-overflow-tooltip="true" />
      <el-table-column label="货转状态" align="center" prop="goodsTransferStatus" />
      <el-table-column label="货转人" align="center" prop="goodsTransferPerson" />
      <el-table-column label="货转时间" align="center" prop="goodsTransferTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.goodsTransferTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="货转重量(吨)" align="center" prop="goodsTransferWeight" width="100" />
      <el-table-column label="件数" align="center" prop="goodsTransferPiece" />
      <el-table-column label="货转凭证" align="center" prop="goodsTransferPicture" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.goodsTransferPicture" :width="50" :height="25"/>
        </template>
      </el-table-column>
      <el-table-column label="结算状态" align="center" prop="goodsTransferSettlementStatus" />
      <el-table-column label="结算客户" align="center" prop="goodsTransferSettlementCustomer" width="300" :show-overflow-tooltip="true" />
      <el-table-column label="结算方式" align="center" prop="goodsTransferSettlementMode" />
      <el-table-column label="免费次数" align="center" prop="goodsTransferFreeTimes" />
      <el-table-column label="货转单价(元/吨)" align="center" prop="goodsTransferPrice" width="120" />
      <el-table-column label="收费重量(吨)" align="center" prop="goodsTransferChargeWeight" width="100"/>
      <el-table-column label="折扣模式" align="center" prop="goodsTransferDiscountMode" />
      <el-table-column label="折扣额度" align="center" prop="goodsTransferDiscountAmount" />
      <el-table-column label="货转费用" align="center" prop="goodsTransferFee" />
      <!--el-table-column label="外部单号" align="center" prop="externalOrderNumber" />
      <el-table-column label="账单编号" align="center" prop="billNumber" />
      <el-table-column label="账单状态" align="center" prop="billStatus" />
      <el-table-column label="告警状态" align="center" prop="alarmStatus" />
      <el-table-column label="告警描述" align="center" prop="alarmDescription" /-->
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="创建者" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改货转记账对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="记账单号" prop="goodsTransferAccountNumber">
          <el-input v-model="form.goodsTransferAccountNumber" placeholder="请输入记账单号" clearable />
        </el-form-item>
        <!--el-form-item label="货转ID" prop="goodsTransferId">
          <el-input v-model="form.goodsTransferId" placeholder="请输入货转ID" clearable />
        </el-form-item-->
        <el-form-item label="货转单号" prop="goodsTransferNumber">
          <el-input v-model="form.goodsTransferNumber" placeholder="请输入货转单号" clearable />
        </el-form-item>
        <el-form-item label="原货权客户" prop="originGoodsRightCustomer">
          <el-select v-model="form.originGoodsRightCustomer" placeholder="请选择原货权客户" style="width: 340px;" clearable filterable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="新货权客户" prop="newGoodsRightCustomer">
          <el-select v-model="form.newGoodsRightCustomer" placeholder="请选择新货权客户" style="width: 340px;" clearable filterable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="货转状态" prop="goodsTransferStatus">
          <el-select v-model="form.goodsTransferStatus" placeholder="请选择货转状态" style="width: 340px;" clearable>
            <el-option
              v-for="dict in dict.type.goods_transfer_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="货转人" prop="goodsTransferPerson">
          <el-input v-model="form.goodsTransferPerson" placeholder="请输入货转人" clearable />
        </el-form-item>
        <el-form-item label="货转时间" prop="goodsTransferTime">
          <el-date-picker clearable
            v-model="form.goodsTransferTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择货转时间"
            style="width: 340px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="货转重量(吨)" prop="goodsTransferWeight">
          <el-input v-model="form.goodsTransferWeight" placeholder="请输入货转重量(吨)" clearable />
        </el-form-item>
        <el-form-item label="件数" prop="goodsTransferPiece">
          <el-input v-model="form.goodsTransferPiece" placeholder="请输入件数" clearable />
        </el-form-item>
        <el-form-item label="货转凭证" prop="goodsTransferPicture">
          <image-upload v-model="form.goodsTransferPicture"/>
        </el-form-item>
        <el-form-item label="结算状态" prop="goodsTransferSettlementStatus">
          <el-select v-model="form.goodsTransferSettlementStatus" placeholder="请选择结算状态" style="width: 340px;" clearable>
            <el-option
              v-for="dict in dict.type.settlement_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算客户" prop="goodsTransferSettlementCustomer">
          <el-select v-model="form.goodsTransferSettlementCustomer" placeholder="请选择结算客户" style="width: 340px;" clearable filterable>
            <el-option
              v-for="dict in customerOptions"
              :key="dict.customerId"
              :label="dict.customerName"
              :value="dict.customerName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结算方式" prop="goodsTransferSettlementMode">
          <el-select v-model="form.goodsTransferSettlementMode" placeholder="请选择结算方式" style="width: 340px;" clearable>
            <el-option
              v-for="dict in dict.type.settlement_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="免费次数" prop="goodsTransferFreeTimes">
          <el-input v-model="form.goodsTransferFreeTimes" placeholder="请输入免费次数" clearable />
        </el-form-item>
        <el-form-item label="货转单价(元/吨)" prop="goodsTransferPrice">
          <el-input v-model="form.goodsTransferPrice" placeholder="请输入货转单价(元/吨)" clearable />
        </el-form-item>
        <el-form-item label="收费重量(吨)" prop="goodsTransferChargeWeight">
          <el-input v-model="form.goodsTransferChargeWeight" placeholder="请输入收费重量(吨)" clearable />
        </el-form-item>
        <el-form-item label="折扣模式" prop="goodsTransferDiscountMode">
          <el-select v-model="form.goodsTransferDiscountMode" placeholder="请选择折扣模式" style="width: 340px;" clearable>
            <el-option
              v-for="dict in dict.type.discount_mode"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="折扣额度" prop="goodsTransferDiscountAmount">
          <el-input v-model="form.goodsTransferDiscountAmount" placeholder="请输入折扣额度" clearable />
        </el-form-item>
        <el-form-item label="货转费用" prop="goodsTransferFee">
          <el-input v-model="form.goodsTransferFee" placeholder="请输入货转费用" clearable />
        </el-form-item>
        <el-form-item label="外部单号" prop="externalOrderNumber">
          <el-input v-model="form.externalOrderNumber" placeholder="请输入外部单号" clearable />
        </el-form-item>
        <el-form-item label="账单编号" prop="billNumber">
          <el-input v-model="form.billNumber" placeholder="请输入账单编号" clearable />
        </el-form-item>
        <el-form-item label="账单状态" prop="billStatus">
          <el-select v-model="form.billStatus" placeholder="请选择账单状态" style="width: 340px;" clearable>
            <el-option
              v-for="dict in dict.type.bill_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="告警状态" prop="alarmStatus">
          <el-input v-model="form.alarmStatus" placeholder="请输入告警状态" clearable />
        </el-form-item>
        <el-form-item label="告警描述" prop="alarmDescription">
          <el-input v-model="form.alarmDescription" placeholder="请输入告警描述" clearable />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" clearable />
        </el-form-item>
        <el-form-item label="园区代码" prop="parkCode">
          <el-input v-model="form.parkCode" placeholder="请输入园区代码" clearable />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAccount, getAccount, delAccount, addAccount, updateAccount } from "@/api/transfers/account";
import { listCustomerOption } from "@/api/customs/custom";

export default {
  name: "Account",
  dicts: ['settlement_status', 'discount_mode', 'sys_yes_no', 'settlement_mode', 'goods_transfer_status', 'bill_status'],
  data() {
    return {
      // 定义列表高度
      tableHeight: 430,
      // 定义查询高度
      queryHeight: 200,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 货转记账表格数据
      accountList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 园区代码时间范围
      daterangeGoodsTransferTime: [],
      // 园区代码时间范围
      daterangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        goodsTransferAccountNumber: null,
        goodsTransferId: null,
        goodsTransferNumber: null,
        originGoodsRightCustomer: null,
        newGoodsRightCustomer: null,
        goodsTransferStatus: null,
        goodsTransferPerson: null,
        goodsTransferTime: null,
        goodsTransferWeight: null,
        goodsTransferPiece: null,
        goodsTransferPicture: null,
        goodsTransferSettlementStatus: null,
        goodsTransferSettlementCustomer: null,
        goodsTransferSettlementMode: null,
        goodsTransferFreeTimes: null,
        goodsTransferPrice: null,
        goodsTransferChargeWeight: null,
        goodsTransferDiscountMode: null,
        goodsTransferDiscountAmount: null,
        goodsTransferFee: null,
        externalOrderNumber: null,
        billNumber: null,
        billStatus: null,
        alarmStatus: null,
        alarmDescription: null,
        remark: null,
        parkCode: null,
        createBy: null,
        createTime: null,
      },
      // 表单参数
      form: {},
      // 字典项客户
      customerOptions: [],
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.getOption();
  },
  mounted() {
    this.$nextTick(() =>{
      // 根据浏览器高度设置初始高度 - 按钮行高度28 - 页码行高度28 - （面包屑+TAB行）高度160
      this.queryHeight = this.$refs.queryForm.$el.offsetHeight;
      this.tableHeight = window.innerHeight - this.$refs.queryForm.$el.offsetHeight - 28 - 28 - 160;
      // 监听浏览器高度变化，改变表格高度
      window.onresize = () =>{
        this.tableHeight = window.innerHeight - this.$refs.queryForm.$el.offsetHeight - 28 - 28 - 160;
      }
    })
  },
  methods: {
    /** 查询货转记账列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeGoodsTransferTime && '' != this.daterangeGoodsTransferTime) {
        this.queryParams.params["beginGoodsTransferTime"] = this.daterangeGoodsTransferTime[0];
        this.queryParams.params["endGoodsTransferTime"] = this.daterangeGoodsTransferTime[1];
      }
      if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
        this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
        this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
      }
      listAccount(this.queryParams).then(response => {
        this.accountList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        goodsTransferAccountId: null,
        goodsTransferAccountNumber: null,
        goodsTransferId: null,
        goodsTransferNumber: null,
        originGoodsRightCustomer: null,
        newGoodsRightCustomer: null,
        goodsTransferStatus: null,
        goodsTransferPerson: null,
        goodsTransferTime: null,
        goodsTransferWeight: null,
        goodsTransferPiece: null,
        goodsTransferPicture: null,
        goodsTransferSettlementStatus: null,
        goodsTransferSettlementCustomer: null,
        goodsTransferSettlementMode: null,
        goodsTransferFreeTimes: null,
        goodsTransferPrice: null,
        goodsTransferChargeWeight: null,
        goodsTransferDiscountMode: null,
        goodsTransferDiscountAmount: null,
        goodsTransferFee: null,
        externalOrderNumber: null,
        billNumber: null,
        billStatus: null,
        alarmStatus: null,
        alarmDescription: null,
        remark: null,
        dataRealm: null,
        parkCode: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeGoodsTransferTime = [];
      this.daterangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.goodsTransferAccountId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加货转记账";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const goodsTransferAccountId = row.goodsTransferAccountId || this.ids
      getAccount(goodsTransferAccountId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改货转记账";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.goodsTransferAccountId != null) {
            updateAccount(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAccount(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const goodsTransferAccountIds = row.goodsTransferAccountId || this.ids;
      this.$modal.confirm('是否确认删除货转记账编号为"' + goodsTransferAccountIds + '"的数据项？').then(function() {
        return delAccount(goodsTransferAccountIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('transfers/account/export', {
        ...this.queryParams
      }, `account_${new Date().getTime()}.xlsx`)
    },
    computeTableHeight(){
      if( this.showSearch==true ){
        this.tableHeight = window.innerHeight - this.queryHeight - 28 - 28 - 160;
      } else {
        this.tableHeight = window.innerHeight - 28 - 28 - 160;
      }
    },
    getOption() {
      /** 字典项客户*/
      listCustomerOption().then(response => {
        this.customerOptions = response.data;

//        console.log('this.customerOptions',this.customerOptions);
      });

    },  
  }
};
</script>
